﻿
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script type="text/javascript" src="../internal.js"></script>
    <script src="../../third-party/jquery-1.10.2.js"></script>
    <style type="text/css">
        * {
            margin: 0;
            padding: 0;
            color: #838383;
        }

        table {
            font-size: 12px;
            margin: 10px;
            line-height: 30px;
        }

        .txt {
            width: 300px;
            height: 21px;
            line-height: 21px;
            border: 1px solid #d7d7d7;
        }
    </style>
</head>
<body>

    <table>
        <tr>
            <td><label for="href">美篇地址：</label></td>
            <td><input class="txt" id="href" type="text" autofocus /></td>
        </tr>
    </table>
    <script type="text/javascript">
        function handleDialogOk() {
            if ($G('href').value) {
                var url = $G('href').value;
                var patt1 = new RegExp("https://www.meipian.cn");
                if (patt1.test(url)) {
                    $.ajax({
                        cache: false,
                        type: "POST",
                        async: false,
                        dataType: "json",
                        contentType: "text/json;charset=utf-8",
                        url: "/Article/GetMeipianArticle?mpurl="+url,
                        success: function (data) {
                            if (data.result) {
                                editor.execCommand('insertHtml', data.model);
                                dialog.close();
                            }
                            else {
                                alert("获取美篇内容失败");
                                return false;
                            }
                        },
                        error:function(jqXHR,textStatus,errorThrown){
                            console.log(jqXHR.statusText);
                            alert("获取美篇内容失败");
                            return false;
                        }
                    });

                } else {
                    alert("不支持地址");
                    return false;
                }

            } else {
                alert("请输入美篇地址");
                return false;
            }
        }
        dialog.onok = handleDialogOk;
        $G('href').onkeydown = function (evt) {
            evt = evt || window.event;
            if (evt.keyCode == 13) {
                handleDialogOk();
                return false;
            }
        }
    </script>
</body>
</html>